//package com.zmn.plat.dubbo.impl.product;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import javax.annotation.Resource;
//
//import org.apache.dubbo.config.annotation.Service;
//import org.springframework.cglib.beans.BeanCopier;
//
//import com.zmn.common.constant.GlobalConsts;
//import com.zmn.common.dto2.ResponseDTO;
//import com.zmn.common.utils.number.NumberUtil;
//import com.zmn.manager.common.database.annotation.ReadOnlyConnection;
//import com.zmn.plat.business.interfaces.product.ServSubsidiaryItemBService;
//import com.zmn.plat.common.constant.ProductConsts;
//import com.zmn.plat.common.dictionary.PlatErrorCodeDict;
//import com.zmn.plat.common.dto.product.ServSubsidiaryItemDIO;
//import com.zmn.plat.common.dto.product.ServSubsidiaryItemDRO;
//import com.zmn.plat.common.exception.PlatException;
//import com.zmn.plat.dubbo.interfaces.product.ServSubsidiaryItemListRemoteService;
//import com.zmn.plat.dubbo.utils.DubboConsts;
//import com.zmn.plat.model.entity.product.ServSubsidiaryItem;
//import com.zmn.plat.model.entity.product.ServSubsidiaryItemQuery;
//import com.zmn.plat.services.interfaces.product.ServSubsidiaryItemService;
//import com.zmn.plat.utils.bean.BeanCopyUtils;
//
//import lombok.extern.slf4j.Slf4j;
//
///**
// * @author tanghongjun
// * @version v1.0 @类说明：
// * @since 2018/10/16 11:30
// */
//@Slf4j
//@Service(version = DubboConsts.INTERFACE_VERSION, validation = "true")
//public class ServSubsidiaryItemListRemoteServiceImpl implements ServSubsidiaryItemListRemoteService {
//    private static final String TAG = "故障服务分组 dubbo 接口";
//
//    @Resource
//    private ServSubsidiaryItemService servSubsidiaryItemService;
//
//    @Resource
//    private ServSubsidiaryItemBService servSubsidiaryItemBService;
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<ServSubsidiaryItemDRO> getById(Integer itemId) {
//        log.info("getById param is:itemId={}", itemId);
//        if (NumberUtil.isNullOrZero(itemId)) {
//            log.error(String.format("[%s]参数:[%s]不能为空", TAG, "itemId"));
//            return ResponseDTO.fromErrorCodeTable(PlatErrorCodeDict.ERROR_CODE_PANAM_NULL);
//        }
//
//        ServSubsidiaryItem servSubsidiaryItem = servSubsidiaryItemService.findByKey(itemId);
//        ServSubsidiaryItemDRO servSubsidiaryItemDRO = new ServSubsidiaryItemDRO();
//        BeanCopyUtils.copyProperties(servSubsidiaryItem, servSubsidiaryItemDRO);
//
//        return ResponseDTO.success(servSubsidiaryItemDRO, "OK");
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<ServSubsidiaryItemDRO>> listByProductIdAndType(Integer productId, Integer type) {
//        log.info("listByProductIdAndType param is:productId={},type={}", productId, type);
//        try {
//            List<ServSubsidiaryItemDRO> list = servSubsidiaryItemBService.listByProductIdAndType(productId, type);
//            return ResponseDTO.success(list);
//        } catch (PlatException e) {
//            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
//        } catch (Exception e) {
//            log.error("listByProductIdAndType error...productId={},type={}", productId, type, e);
//            return ResponseDTO.fail(GlobalConsts.FAILD_MSG);
//        }
//
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<ServSubsidiaryItemDRO>> listByDIO(ServSubsidiaryItemDIO servSubsidiaryItemDRO) {
//        log.info("listByDIO param is:servSubsidiaryItemDRO={}", servSubsidiaryItemDRO);
//
//        ServSubsidiaryItemQuery query = new ServSubsidiaryItemQuery();
//        BeanCopyUtils.copyProperties(servSubsidiaryItemDRO, query);
//
//        List<ServSubsidiaryItem> servSubsidiaryItemList = servSubsidiaryItemService.listByQuery(query);
//
//        return this.listToDRO(servSubsidiaryItemList);
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<ServSubsidiaryItemDRO>> listFaultByProductId(Integer productId) {
//        log.info("listFaultByProductId param is:productId={}", productId);
//
//        List<ServSubsidiaryItem> servSubsidiaryItemList = servSubsidiaryItemService.listByProductIdAndType(productId, ProductConsts.SERV_SUB_TYPE_HITCH);
//
//        return this.listToDRO(servSubsidiaryItemList);
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<ServSubsidiaryItemDRO>> listWarrantyByProductId(Integer productId) {
//        log.info("listWarrantyByProductId param is:productId={}", productId);
//
//        List<ServSubsidiaryItem> servSubsidiaryItemList = servSubsidiaryItemService.listByProductIdAndType(productId, ProductConsts.SERV_SUB_TYPE_GUARANTEE);
//
//        return this.listToDRO(servSubsidiaryItemList);
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<ServSubsidiaryItemDRO>> listAll() {
//        List<ServSubsidiaryItem> servSubsidiaryItemList = servSubsidiaryItemService.listAll();
//
//        return this.listToDRO(servSubsidiaryItemList);
//    }
//
//    private ResponseDTO<List<ServSubsidiaryItemDRO>> listToDRO(List<ServSubsidiaryItem> servSubsidiaryItemList) {
//        if (servSubsidiaryItemList == null || servSubsidiaryItemList.size() == 0) {
//            log.error("listToDRO没有相关数据,errorCode:{}", PlatErrorCodeDict.ERROR_CODE_PRODUCT_SUBSIDIARY_ITEM_NO_DATA);
//            return ResponseDTO.fromErrorCodeTable(PlatErrorCodeDict.ERROR_CODE_PRODUCT_SUBSIDIARY_ITEM_NO_DATA);
//        }
//
//        List<ServSubsidiaryItemDRO> items = new ArrayList<>();
//        ServSubsidiaryItemDRO servSubsidiaryItemDRO;
//        BeanCopier copier = BeanCopier.create(ServSubsidiaryItem.class, ServSubsidiaryItemDRO.class, false);
//        for (int i = 0; i < servSubsidiaryItemList.size(); i++) {
//            servSubsidiaryItemDRO = new ServSubsidiaryItemDRO();
//            copier.copy(servSubsidiaryItemList.get(i), servSubsidiaryItemDRO, null);
//            items.add(servSubsidiaryItemDRO);
//        }
//
//        return ResponseDTO.success(items);
//    }
//}
